﻿    
    var vLyxh = 0;
    
    

    
    function onRowClick(item , id)
    {
        if(vType == 0)
        {
            if(listGrly.getCell(id,0).text == "1")
            {
                vLyxh = 1;
            }
            else
            {
                vLyxh = 2;
            }
        }
    }
    
    function OnUpdateQx(type)
    {
        var message = ""
        var count   = ""
        var vRowp   = ""
        var bmList  = "" 
        if(type != vType && vType != null)
        {
            if(vType == 1)
                message = "该光路已经是单纤光路！"
            else
                message = "该光路已经是双纤光路！"
            CtnDlg.msg(message)
            return         
        }  
        //双改单
        if(vType == 0)
        {
            if(vLyxh == 0)
            {
                CtnDlg.msg("请选择要删除的纤芯！")
                return
            } 
            //增加提示信息
            if(type == 0 && vLyxh != 0)
            {
                CtnDlg.confirm("是否确定将双纤改为单纤！",IsGq,type)
            }
        } 
        else if(vType == 1)
        {
            bmList = GetBmListByLy();
            
            var params = [m_GrType,bmList,3,3,1,1,1,GetSelRes];  //grtype,bmlist,qsentlay,zzentlay,qx,bjump,bcfg,fun
            top.ExecuteATool(m_vt.FUN_SELJXGQ,params)
        }
        
    }
    
    
    function GetBmListByLy()
    {
        var BmList = ""
        for(var i = 0 ; i < listGrly.arrRow.length; i++)
        {
            var vData = listGrly.getCell(i,1).text;
            var TmpBm = vData.split("(")[0];
            var vData11 = listGrly.getCell(i,4).text;
            var TmpBm11 = vData11.split("(")[0];
            BmList += TmpBm + "|" + TmpBm11;
            if(i + 1 < listGrly.arrRow.length)
            {
                BmList += "|"
            }
        }
        return BmList;
    }
    
    function GetSelRes(dlg)
    {
        var Res = dlg.wnd.ReturnVal();
        if(Res)
        {   
            dlg.close(); 
            UpdateGrQx(1,Res);
        }
    }
    
    //////////
    function IsGq(bflg,type)
    {
        if(bflg)
        {
            UpdateGrQx(type,"") 
        }
    }
    
    
    /////////////
    function UpdateGrQx(type,QxInfo)
    {
        var serverUrl = "_method=UpdateGrQx&type="+type+"&xml="+escape(QxInfo)+"&GrBm="+escape(mGrBm)+"&LyXh="+escape(vLyxh)
        var vXml = CtnTrans.getText("/main.ashx?", "post", serverUrl)
        if (!CtnError.validate(vXml))
        {
            CtnError.show()
            return;
        }
        else
        {
            var XmlVal = GetXmlDoc(vXml)
            var nodes = XmlVal.selectNodes('Items/Item');
            var Resultnodes = nodes[0].selectNodes('Result')
            var Tmpdata = $XML(Resultnodes[0],"data")
            var Tmpval = $XML(Resultnodes[0],"val")
            CtnDlg.msg(Tmpdata);
            if(Tmpval == "Sucess")
            {   
                ToMod()
            }
        }
    }
    
    function GetXmlDoc(vData)
    {
        var XmlDoc = CtnXML.getXmlDoc();
        if (vData.indexOf("<?xml") == -1)
        {
            vData = "<?xml version='1.0' encoding='gb2312' ?><Items>" + vData + "</Items>";
        }
        try
        {
            XmlDoc.loadXML(vData);
        }
        catch (e)
        {
            CtnDlg.msg("xml数据不符合规范！");
            return false;
        }
        return XmlDoc
    }